#-*- coding: utf-8 -*-
# autor: João Rebocho Nº6035
# data: 4/11/2013
# obs: Aula prática 7
#

#Matplotlib
import numpy as np
import matplotlib.pyplot as plt

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

#the histogram of the data
n, bins, patches = plt.hist(x, 50, normed = 1, 
		facecolor = 'g', alpha = 0.75)

plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu = 100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
plt.show()

from mpl_toolkits.mplot3d import Axes3D
import matplotlib
import numpy as np
from matplotlib import cm
from matplotlib import pyplot as plt
step = 0.04; maxval =1.0; fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
r = np.linspace(0,1.25, 50); p = np.linspace(0, 2* np.pi, 50)
R,P = np.meshgrid(r,p)
X,Y = R*np.cos(P), R*np.sin(P); Z = ((R**2 -1)**2)
ax.plot_surface(X,Y,Z, rstride = 1, cstride = 1, cmap = cm.YlGnBu_r)
ax.set_zlim3d(0,1);
ax.set_xlabel(r'$\phi_\mathrm{real}$')
ax.set_ylabel(r'$\phi_\mathrm{im}$')
ax.set_zlabel(r'$V(\phi)$')
plt.show()

#Numpy
import numpy as np
A = np.random.random((5,5))
B = np.random.random((5,5))
print np.sin(A)
#multiplicação matricial
C = A.dot(B)
#calculo da Inversa
C = np.linalg.inv(A)
print C
